package com.gjy.sql.oracle.oa;

import com.gjy.sql.oracle.OracleUtil;
import org.junit.Test;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-07-12 10:35:35
 */
public class SelectTest {

    private static final Connection connection = OracleUtil.connection();

    @Test
    public void test4() throws Exception {
        String sql = "select * from cfg_settle_app";
        Connection connection = OracleUtil.connection();
        PreparedStatement ps = connection.prepareStatement(sql);
        ResultSet rs = ps.executeQuery();

        if (rs.next()) {
            String tbsj = rs.getString("tbsj");
            System.out.println(tbsj);
        }
    }

    @Test
    public void test3() throws Exception {
        String sql = "select * from UF_HRSYNTIME where id = ?";
        Connection connection = OracleUtil.connection();
        PreparedStatement ps = connection.prepareStatement(sql);
        ps.setString(1, "1");
        ResultSet rs = ps.executeQuery();

        if (rs.next()) {
            String tbsj = rs.getString("tbsj");
            System.out.println(tbsj);
        }
    }

    @Test
    public void test2() throws Exception {
        String sql = "select * from formtable_main_207 where requestid = ?";
        Connection connection = OracleUtil.connection();
        PreparedStatement ps = connection.prepareStatement(sql);
        ps.setString(1, "2814506");
        ResultSet rs = ps.executeQuery();

        if (rs.next()) {
            String fxxx = rs.getString("fxxx");
            System.out.println(fxxx);
        }
    }

    @Test
    public void test1() throws Exception {
        String sql = "SELECT * FROM FORMTABLE_MAIN_1116 WHERE REQUESTID = ?";
        PreparedStatement ps = connection.prepareStatement(sql);
        ps.setInt(1, 1415414);

        ResultSet rs = ps.executeQuery();
        if (rs.next()) {
            String fxxx = rs.getString("FXXX");
            System.out.println(fxxx);
        }
    }
}
